Repository navigation
Conversation
Cloudflare's Worker version list can trail a write by minutes. Before the upload, wait while the list lacks the active version. After the upload, wait while the list still equals the baseline, on a schedule of about 5.5 minutes instead of 250 ms and 500 ms. Failed reads keep their two quick retries. Refs voidzero-dev#891
0froq
left a comment
There was a problem hiding this comment.
Looked into this and commented
| for ( | ||
| let attempt = 0; | ||
| previous.versionId !== null && | ||
| recent !== null && |
There was a problem hiding this comment.
The waits only continue while the read succeeded. A versions.list whose two pages disagree returns a non-zero status, which readRecentCloudflareVersionIds turns into null. That case gets 0 waits before the upload and only the 250/500 ms retries after it. Page 2 is only read above 10 versions, so this is the shape of the 20:08 inheritance-source-unavailable report in #891, not the stale-but-readable shape this fixes.
Not a regression, but "Fixes #891 for the version-list paths" would close the issue with that symptom unchanged. Either classify the page-overlap failure and retry it on this schedule, or narrow the claim.
There was a problem hiding this comment.
Fixed in c348401. cf-version-runner.ts now marks the page-overlap failure ("version history changed during inspection") as failure: 'version-history-changed'. activateCloudflareVersion retries that failure on STALE_VERSION_HISTORY_DELAYS_MS both before the upload and after it. If the overlap outlasts the schedule it still ends in inheritance-source-unavailable. Other failed reads are unchanged: no wait before the upload, two quick retries after it. Tests cover recover, exhausted and a different failure, before and after the upload, plus the runner marker. The PR body now lists the overlap case. triggers-failed is still untouched.
| * Waits between reads of Cloudflare's Worker version list while it lags behind a write. | ||
| * Defaults to {@link STALE_VERSION_HISTORY_DELAYS_MS}. | ||
| */ | ||
| versionHistoryRetryDelaysMs?: ReadonlyArray<number>; |
There was a problem hiding this comment.
STALE_VERSION_HISTORY_DELAYS_MS is this option's documented default but is not exported from src/index.ts, so a caller that wants to extend the schedule has to copy the array. Add it to the ./version.ts export list next to activateCloudflareVersion.
There was a problem hiding this comment.
Fixed in c348401. STALE_VERSION_HISTORY_DELAYS_MS is now exported from src/index.ts next to activateCloudflareVersion.
The version list reads page 2 only above 10 versions. If a write lands between the two page reads, the pages overlap and the read fails. That failure ended the pre-upload check with no wait and left only two quick retries after the upload. The runner now marks this failure as version-history-changed, and both waits retry it on the same schedule as a stale list. Other failures keep their behavior, and an overlap that outlasts the schedule still stops with inheritance-source-unavailable. Export STALE_VERSION_HISTORY_DELAYS_MS from the package entry. Refs voidzero-dev#891
|
in !['not-found', 'durable-migration', 'containers-unavailable'].includes(envelope.failure))should include 'version-history-changed'. Not reachable today (the cf runner is in-process), but the whitelist and the failure union in Thank you! |
|
Slop review:
|
The process envelope decoder accepted only three of the four runner failures, so a version-history-changed envelope from a child process would have been rejected as invalid. The cf runner is in-process today, so this path was not reachable. The accepted failures are now a record keyed by the CloudflareCommandResult failure union, so a failure added to the union fails the typecheck until it is accepted here too. Refs voidzero-dev#891
|
Fixed in f72b076. |
A rollback during either version list wait was not seen until after the candidate receipt was saved with the old active version as its parent. The deploy then stopped, and the next deploy failed on that receipt. After a wait, production is now read again before the upload and before the receipt is saved. If it changed, the deploy stops with deployment-changed and saves no receipt. A rollback to a version older than the ten listed versions can never appear in the list, but the pre-upload check waited the whole schedule for it. The active version's number is now read with versions.view, and the deploy waits only when that number is not below the list's lowest number. A number that cannot be read keeps the wait. Refs voidzero-dev#891
|
Fixed in e4fbe90. Rollback during a wait. After the pre-upload wait, The same hazard exists on Rollback beyond the listed versions. This applies to the pre-upload wait only. The post-upload wait compares against the pre-upload baseline and does not look for the active version. When the list does not contain the active version, the deploy now reads that version once with |
cpojer
left a comment
There was a problem hiding this comment.
Looks good to me, I'd like a review by @Brooooooklyn before we merge.
Fixes #891 for the version-list paths. The
triggers-failedcase in the issue is not changed here.Change
Cloudflare's Worker version list can trail a write by minutes. The deploy now waits for it in the two places where the expected state is known:
deployments statusreported. This read had no retry.versions.listfails because its two pages disagreed ("The Cloudflare Worker version history changed during inspection"). The runner now marks that failure asversion-history-changed, and it is retried on the same schedule. Page 2 is read only above 10 versions, so this is theinheritance-source-unavailableshape in the second report on Cloudflare deploy stops on a lagging Worker version list (inheritance-source-changed, triggers-failed) #891.After either wait, production is read again: before the upload, and before the candidate receipt is saved. If a rollback or another deploy changed it during the wait, the deploy stops with
deployment-changedand saves no receipt, so the next deploy does not find a receipt with the wrong parent. Production is read again only after a wait.These waits use
STALE_VERSION_HISTORY_DELAYS_MS: 250 ms doubling up to 30 s, 17 waits, about 5.5 minutes in total. Each wait checksverifyUploader()and the first one reports progress. The schedule can be overridden with the newversionHistoryRetryDelaysMsoption.STALE_VERSION_HISTORY_DELAYS_MSis exported from the package entry.Why this length: in the runs in #891 a new version was still missing 52 s after creation and was listed within about 4.5 minutes. #880 and #868 retried for a second or less, which does not reach that. If maintainers want a shorter cap, change the constant.
What does not change
inheritance-source-changedbefore the upload,inheritance-source-unavailableafter it). Nothing is uploaded when the pre-upload wait runs out.numberis read withversions.view; the wait happens only when that number is not below the list's lowest number. If the number cannot be read (failed or thrown read, or no integernumber; the API marks the field optional), the deploy waits as for a lagging list, since a version the list trails may not be readable yet either.stabilizeCloudflareVersionTriggersis untouched. The logs in Cloudflare deploy stops on a lagging Worker version list (inheritance-source-changed, triggers-failed) #891 do not show what its reads returned.Tests
packages/deploy-cloudflare/test/unit/version.test.ts:packages/void/test/unit/cf-version-runner.test.tschecks theversion-history-changedmarker.deployment-changed, andrecordVerifiedCandidateis never called.versions.viewstill waits the whole schedule.The new pre-upload tests and the changed stale-list case fail on
mainand pass here (5 failures without the change; measured before the page-overlap commit).Verified locally
Run in a shell with no
CLOUDFLARE_*,CF_*or wrangler variables (env | grep -ciE 'cloudflare|^CF_|wrangler'printed 0). The tests injectrunWrangler, so nocforwranglerprocess starts.vp test run packages/deploy-cloudflare/test/unit/version.test.ts: 237 passed after the page-overlap commit (231 before)vp check,vp run check:types(35/35) andvp test run packages/deploy-cloudflare packages/deploy-core packages/void/test/unitwere re-run: 10069 passed, 17 failed. The 17 areinit.test.ts(16) andnitro.test.ts(1), which also fail on the commit before this one in the same shell.vp check: no warnings, lint errors or type errorsvp run check:types: 35/35 successfulvp run test:all: 92 of 93 tasks passed. The one failing task wasplatform-api-integration-threads, 12 tests, because Playwright's Chromium was not installed. Afterplaywright install chromiumthe six failing files passed (204 tests).